#include "Socket.hpp"
#include "TcpServer.hpp"
#include "Protocol.hpp"
#include <memory>

void hander(NetWork::Socket* socket)
{
    while(true)
    {
        ns_protocol::Request req;
        int n = recv(socket->GetSockFd(),&req,sizeof(req),0);
        if(n <= 0)
            return;
        req.Debug();
    }
}


// ./server port
int main(int argc, char* argv[])
{
    if(argc != 2)
    {
        std::cout << "Usage: " << argv[0] << " port" << std::endl;
    }

    uint16_t port = std::stoi(argv[1]);
    std::unique_ptr<TcpServer> tcp(new TcpServer(port,hander));
    tcp->Loop();
    return 0;
  
}